﻿using Newtonsoft.Json;

namespace WeiXin.Base.Card.Message
{
    /// <summary>
    /// 创建卡券之后，开发者可以通过设置微信买单接口设置该card_id支持自助核销功能。
    /// 值得开发者注意的是，设置自助核销的card_id必须已经配置了门店，否则会报错。
    /// </summary>
    public class SelfConsumeCellMessage:BaseMessage
    {
        public SelfConsumeCellMessage() {
            base.PostUrl = "https://api.weixin.qq.com/card/selfconsumecell/set?access_token={0}";
        }

        /// <summary>
        /// 卡券ID
        /// </summary>
        [JsonProperty(NullValueHandling =NullValueHandling.Include,Required =Required.Always)]
        public string card_id { get; set; }

        /// <summary>
        /// 是否开启自助核销功能，填true/false
        /// </summary>
        [JsonProperty(NullValueHandling = NullValueHandling.Include, Required = Required.Always)]
        public bool is_open { get; set; }

        /// <summary>
        /// json序列化
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return JsonConvert.SerializeObject(this);
        }

        /// <summary>
        /// 错误码，0为正常；45046为该card_id已经设置了买单功能，不可变更为自助核销功能，设置冲突
        /// </summary>
        /// <returns></returns>
        public override bool Send(out string sReturnMessage)
        {
            return base.Send(out sReturnMessage);
        }
    }
}
